<template>
    <div>
        <el-table border :data="list" style="width: 100%">
            <el-table-column prop="name" label="班级" />
            <el-table-column prop="num" label="人数" />
            <el-table-column label="操作" >
<template #default="scope">
    <!-- {{scope.row}} -->
    <el-button type="primary" @click="faqi(scope.row)">发起作业</el-button>
</template>
</el-table-column>
<!-- <el-table-column prop="address" label="Address" /> -->
</el-table>
</div>
</template>
<script setup>
    import {
        onMounted,
        ref
    } from 'vue'
    import {
        chakan,
        add
    } from "~/api/xm.js"
    import {
        useStore
    } from 'vuex'
    import {
        ElMessage,
        ElMessageBox
    } from 'element-plus'
    const store = useStore()
    const list = ref([])

    function faqi(row) {
        console.log(row);
        ElMessageBox.prompt('请输入课程名称', {
                confirmButtonText: '发起',
                cancelButtonText: '取消',
            })
            .then(({
                value
            }) => {
                add({
                    name: value,
                    banjiId: row.id,
                    laoshi: store.state.name,
                    laoshiId: store.state.studentId
                })
                console.log(value);
                ElMessage({
                    type: 'success',
                    message: `发起成功`,
                })
            })
    }
    onMounted(() => {
        chakan({
            ids: store.state.banjiId
        }).then(res => {
            list.value = res.data
            console.log(res);
        })
    })
</script>